#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;
int bottom(int a)
{
    if (a <= 1) return 0;
    if (a == 2) return 1;
    return a / 3 + bottom(a % 3 + a / 3);
}
/*int main() {
    int a;
    while (cin >> a)
    {
        int tmp = bottom(a);
        if (tmp != 0)
            cout << tmp << endl;
        else
            break;
    }
    return 0;
}*/